<?xml version="1.0"?>

<configuration>

    <property>
        <name>yarn.resourcemanager.cluster-id</name>
        <value>{{ yarn_cluster_name }}</value>
    </property>
    <property>
        <name>yarn.resourcemanager.ha.rm-ids</name>
        <value>rm1,rm2</value>
    </property>
    <property>
        <name>yarn.resourcemanager.ha.enabled</name>
        <value>true</value>
    </property>
    <property>
        <name>yarn.resourcemanager.ha.automatic-failover.enabled</name>
        <value>true</value>
    </property>
    <property>
        <name>yarn.resourcemanager.hostname.rm1</name>
        <value>{{ rm1_host }}</value>
    </property>
    <property>
        <name>yarn.resourcemanager.hostname.rm2</name>
        <value>{{ rm2_host }}</value>
    </property>
    <property>
        <name>yarn.resourcemanager.address.rm1</name>
        <value>{{ rm1_host }}:8032</value>
    </property>
    <property>
        <name>yarn.resourcemanager.address.rm2</name>
        <value>{{ rm2_host }}:8032</value>
    </property>
   <property>
         <name>yarn.resourcemanager.scheduler.address.rm1</name>
         <value>{{ rm1_host }}:8030</value>
   </property>
   <property>
         <name>yarn.resourcemanager.scheduler.address.rm2</name>
         <value>{{ rm2_host }}:8030</value>
   </property>
   <property>
         <name>yarn.resourcemanager.webapp.address.rm1</name>
         <value>{{ rm1_host }}:8088</value>
   </property>
   <property>
         <name>yarn.resourcemanager.webapp.address.rm2</name>
         <value>{{ rm2_host }}:8088</value>
   </property>
   <property>
       <name>yarn.resourcemanager.recovery.enabled</name>
       <value>true</value>
   </property>
   <property>
       <name>yarn.resourcemanager.work-preserving-recovery.enabled</name>
       <value>true</value>
   </property>
    <property>
        <name>yarn.resourcemanager.store.class</name>
        <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
    </property>
    <property>
        <name>yarn.resourcemanager.scheduler.class</name>
        <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler</value>
    </property>
    <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle,spark_shuffle</value>
    </property>
    <property>
        <name>yarn.nodemanager.aux-services.mapreduce_shuffle.class</name>
        <value>org.apache.hadoop.mapred.ShuffleHandler</value>
    </property>
    <property>
        <name>yarn.nodemanager.aux-services.spark_shuffle.class</name>
        <value>org.apache.spark.network.yarn.YarnShuffleService</value>
    </property>
    <property>
        <name>spark.shuffle.service.port</name>
        <value>7337</value>
    </property>
    <property>
        <name>yarn.resourcemanager.zk-address</name>
        <value>{{ yarn_zk_address }}</value>
    </property>
    <property>
        <name>yarn.resourcemanager.zk.state-store.address</name>
        <value>{{ yarn_zk_address }}</value>
    </property>
    <property>
        <name>yarn.nodemanager.local-dirs</name>
        <value>{{ nodemanager_local_dirs }}</value>
    </property>
    <property>
        <name>yarn.nodemanager.log-dirs</name>
        <value>{{ nodemanager_log_dirs }}</value>
    </property>
<!-- nodemanager restart start -->
    <property>
        <name>yarn.nodemanager.recovery.enabled</name>
        <value>true</value>
    <description>默认为false,设置为true启用该特性</description>        
    </property>
    <property>
        <name>yarn.nodemanager.recovery.dir</name>
        <value>{{ nodemanager_recovery_dir }}</value>
    <description>NM保存container状态的本地目录</description>    
    </property>
    <property>
        <name>yarn.nodemanager.address</name>
        <value>0.0.0.0:23998</value>
    <description>container与nodemanager连接的端口，要设置一个固定端口。默认是随机端口</description>            
    </property>
<!-- nodemanager restart end  -->

<!-- 聚合日志 start -->
    <property>
        <name>yarn.log-aggregation-enable</name>
        <value>true</value>
    </property>
    <property>
        <name>yarn.log-aggregation.retain-check-interval-seconds</name>
        <value>1800</value>
    </property>
    <property>
        <name>yarn.log.server.url</name>
        <value>http://{{ jobhistory_host }}:19888/jobhistory/logs</value>
    </property>
    <property>
        <name>yarn.log-aggregation.retain-seconds</name>
        <value>2592000</value>
    </property>
<!-- 聚合日志 end -->

<!-- 调优 start  -->
    <property>
        <name>yarn.nodemanager.resource.memory-mb</name>
        <value>{{ (ansible_memtotal_mb * 0.9) | int // 1  }}</value>
    </property>
    <property>
        <name>yarn.nodemanager.resource.cpu-vcores</name>
        <value>{{ (ansible_processor_vcpus * 0.9) | int // 1  }}</value>
    </property>
    <property>
        <name>yarn.resourcemanager.connect.retry-interval.ms</name>
        <value>2000</value>
    </property>
    <property>
        <name>yarn.scheduler.minimum-allocation-mb</name>
        <value>1024</value>
    </property>
    <property>
        <name>yarn.scheduler.maximum-allocation-mb</name>
        <value>{{ (ansible_memtotal_mb * 0.9) | int // 1  }}</value>
    </property>
    <property>
        <name>yarn.scheduler.minimum-allocation-vcores</name>
        <value>1</value>
    </property>
    <property>
        <name>yarn.scheduler.maximum-allocation-vcores</name>
        <value>{{ (ansible_processor_vcpus * 0.9) | int // 1  }}</value>
    </property>
    <property>
        <name>yarn.nodemanager.disk-health-checker.min-free-space-per-disk-mb</name>
        <value>1024</value>
    </property>

<!-- 调优 end  -->

</configuration>
